package schoolWork.work05.test7;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class MyJFrame extends JFrame implements ActionListener {
    JLabel jLabel = new JLabel("请选择认证方式:");
    JComboBox cmb = new JComboBox(new String[]{
            "身份证","护照","社会保障卡","驾驶证"
    });
    JTextField jTextField = new JTextField(20);
    public MyJFrame(){
        setLayout(new FlowLayout());



        cmb.setEditable(true);
        cmb.setSelectedIndex(0);
        cmb.addActionListener(this);

        add(jLabel);
        add(cmb);
        add(jTextField);

        setSize(640,280);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setLocationRelativeTo(null);
        setVisible(true);
    }



    @Override
    public void actionPerformed(ActionEvent e) {
        if(e.getSource() == cmb)
            jTextField.setText("您选择的认证方式是："+cmb.getSelectedItem());
    }
}
